// Quantitative Angiogram Analysis System
//
// Copyright ?Ping Zou, 2007
// sg71.cherub@gmail.com

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI;

namespace eee.Sheffield.PZ.QAAS
{
    public enum FilterFormType { None, FloodFill, GVF, Threshold, MedianSmooth, TwoImages, GVFThinning, ZouRockettTracking}

    public partial class FilterForm : DockContent
    {        
        #region Fields
        private IFilterControl _filterControl = null;
        //private FilterFormType _filterFormType = FilterFormType.None;
        //private MainForm _mainForm = null;
        //private ImageDoc _imageDoc = null;
        #endregion
        
        #region Properties
        public IFilterControl FilterControl 
        { 
            get { return _filterControl; }
            //set 
            //{
            //    if (_filterControl != null)
            //        _filterControl.Dispose();
            //    _filterControl = value; 
            //} 
        }
        //public ImageDoc ImageDoc { set { _imageDoc = value; } }
        //public MainForm MainForm { set { _mainForm = value; } }
        #endregion

        #region Constructor
        public FilterForm()
        {
            InitializeComponent();
        } 
        #endregion

        #region methods
        //public void Set()
        //{
        //    Set(_filterFormType);
        //} // Set()

        //public void Set(FilterFormType filterFormType)
        //{
        //    _filterFormType = filterFormType;
        //    // dispose current control
        //    if (_filterControl != null)
        //        _filterControl.Dispose();

        //    // set new controls
        //    switch (_filterFormType)
        //    {
        //        case FilterFormType.FloodFill:
        //            _filterControl = new FloodFillFilterControl(_mainForm, _imageDoc);
        //            break;
        //        case FilterFormType.GVF:
        //            _filterControl = new GVFFilterControl(_mainForm, _imageDoc);
        //            break;
        //        default:
        //            break;
        //    }

        //    LoadFilterControl(_filterControl);
        //} // Set()

        public void Set(IFilterControl filterControl)
        {
            if (filterControl != null)
            {
                if (_filterControl != null)
                    _filterControl.Dispose();
                _filterControl = filterControl; 
                LoadFilterControl(_filterControl);
            }
        } // Set()

        private void LoadFilterControl(IFilterControl filterControl)
        {
            this.Controls.Add((Control)filterControl);
            // TODO: reflect to specific filter control
            this.Name = filterControl.Flag;
            this.TabText = filterControl.Flag;
            this.Text = filterControl.Flag;
            ((Control)filterControl).ResumeLayout(false);
            ((Control)filterControl).PerformLayout();
            this.ResumeLayout(false);
        } // Load()

        //public void Reload()
        //{
        //    if (_filterControl != null && _imageDoc != null)
        //        ((FilterControl)_filterControl).ImageDoc = _imageDoc;
        //    _filterControl.Reload();            
        //} // Reload()
        #endregion
    }
}